package com.example.testspringes.jiehun;

import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.example.testspringes.utils.HttpClientUtil;
import org.springframework.http.ResponseEntity;
import org.springframework.stereotype.Component;
import org.springframework.web.client.RestTemplate;

import javax.annotation.Resource;
import java.util.Map;

/**
 * @Description: //TODO
 * @ProjectName: testspringes
 * @Package: com.example.testspringes.jiehun
 * @Author: FX
 * @CreateDate: 2019/4/11 14:07
 * @Version: 1.0
 * Copyright: Copyright (c) 2019
 */

public class Thread implements Runnable {

    @Override
    public void run() {

        try {
            String url="http://v.juhe.cn/laohuangli/d?date="+Queue.queue.take()+"&key=c973ddcc0f55d9f9596c912acf1c4b07";
           // ResponseEntity<Map> forEntity = restTemplate.getForEntity(url, Map.class);
            //Map<String,Object> body = forEntity.getBody();
            String s = HttpClientUtil.doGet(url, null);
            JSONObject jsonObject = JSON.parseObject(s);
            Map<String,String> result = (Map<String, String>)jsonObject.get("result");
            //Map<String,String> result = (Map<String, String>) body.get("result");
            //String yi = result.get("yi");
            System.out.println(jsonObject);
            System.out.println(result);
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
    }
}
